The Component Manager allows your component to capture another component. When a component is captured, the Component Manager removes the captured component from its list of available components. The FindNextComponent function does not return information about captured components. Also, other applications or clients cannot open or access captured components unless they have previously received a component identifier or component instance for the captured component. The routines described in this section allow your component to capture and uncapture other components.
Typically, your component captures another component when you want to override all or some of the features provided by a component or to provide new features. For example, a component called NewMath might capture a component called OldMath. Suppose the NewMath component provides a new function, DoExponent . Whenever NewMath gets an exponent request, it can handle the request itself. For all other requests, NewMath might call the OldMath component to perform the request.
After capturing a component, your component might choose to target a particular instance of the captured component. For information on targeting a component instance, see "Responding to the Target Request," and "Targeting a Component Instance" .
Use the CaptureComponent function to capture a component. Use the UncaptureComponent function to restore a previously captured component to the search list.
The CaptureComponent function allows your component to capture another component. In response to this function, the Component Manager removes the specified component from the search list of components. As a result, applications cannot retrieve information about the captured component or gain access to it. Current clients of the captured component are not affected by this function.
FUNCTION CaptureComponent (capturedComponent: Component;
capturingComponent: Component)
: Component;
The CaptureComponent function removes the specified component from the search list of components and returns a new component identifier. Your component can use this new identifier to refer to the captured component. For example, your component can open the captured component by providing this identifier to the OpenComponent function. Your component must provide this identifier to the UncaptureComponent function to specify the component to be restored to the search list.
If the component specified by the capturedComponent parameter is already captured, the CaptureComponent function returns a component identifier set to NIL .
See "Responding to the Target Request" and "Targeting a Component Instance" for information about target requests. For information related to the Component Manager's use of its list of available components, see FindNextComponent for details on the FindNextComponent function and OpenDefaultComponent for details on the OpenDefaultComponent function. See "Registering Components," for details of the component registration routines.
The UncaptureComponent function allows your component to uncapture a previously captured component.
FUNCTION UncaptureComponent (aComponent: Component): OSErr;